<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div class="button">
        <input type="button" value="AAA">
        <input type="button" value="BBB">
        <input type="button" value="CCC">
        <input type="button" value="DDD">
        <input type="button" value="EEE">
        <input type="button" value="FFF">
    </div>

</body>
</html>
<script>
    window.onload = function () {
        var input = document.querySelector(".button").children;
        for (var i=0;i<input.length;i++){
            input[i].index = i;
            input[i].onclick = function () {
                console.log(this.index)
            }
        }
    }
</script>